#ifndef SCENE_H_
#define SCENE_H_

#ifdef _WIN32
#include <windows.h>
#endif

#include <list>

#include "geom.h"
#include "KeyboardInterface.h"

class MyWindow;
class KeyboardInterface;
class MouseInterface;
class Entity;

class Scene
{
public:
    Scene(MyWindow* window);
    virtual ~Scene();

    virtual bool init() = 0;
    virtual void prepare(float dt) = 0;
    virtual void render() = 0;
    virtual void shutdown() = 0;

    virtual void onResize(int width, int height) = 0;

    MyWindow* getWindow() { return m_window; }
    void setWindow(MyWindow* window) { m_window = window; }

    bool isButtonPressed(int button) const;
    bool isButtonHold(int button) const;
    bool hasButtonBeenReleased(int button) const;
    void getMousePos(int& x, int& y);
    bool isKeyPressed(MyKeyCode code);

    Dimension getScreenSize(void) const { return m_screenSize; }

    Scene* nextScene(void) { return m_nextScene; }

    typedef std::list<Entity*>::iterator EntityIterator;
    typedef std::list<Entity*>::const_iterator ConstEntityIterator;

protected:
    std::list<Entity*> m_entities;
    MyWindow* m_window;
    KeyboardInterface* m_keyboard;
    MouseInterface* m_mouse;
    Dimension m_screenSize;
    Scene* m_nextScene;

    void registerEntity(Entity* entity);
    void unregisterEntity(Entity* entity);
    void clearDeadEntities();

};

#endif // SCENE_H_
